package qst.com.bacK.mapper;

import org.apache.ibatis.annotations.*;
import qst.com.bacK.pojo.entity.PersonalityDimension;

import java.util.List;

/**
 * Author:   msh
 * Date:     2024/10/11 下午4:54
 * Description:
 */
public interface DimensionMapper {
    @Select("select * from personality_dimension where assessment_id = #{assessmentId}")
    List<PersonalityDimension> findByAssessment(int id);

    @Delete("delete from personality_dimension where id = #{id}")
    void delete(int id);

    @Select("select * from personality_dimension where id = #{id}")
    PersonalityDimension findById(int id);

    @Select("select * from personality_dimension where assessment_id = #{0} and title = #{1}")
    PersonalityDimension findByAssessmentAndTitle(int assessmentId, String title);

    @Insert("insert into personality_dimension(assessment_id,title,depict) values(#{assessmentId},#{title},#{depict})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(PersonalityDimension kp);

    @Update("update personality_dimension set assessment_id = #{assessmentId},title = #{title},depict = #{depict} where id = #{id}")
    void update(PersonalityDimension kp);

    @Select("select id,title,depict,assessment_id from personality_dimension where id in (select dimension_id from question_dimension where question_id=#{id})")
    List<PersonalityDimension> findDimensionByQuestion(Integer id);
}
